//
//  NDProgressHUD.swift
//  NDAi
//
//  Created by 丸子 on 2024/6/27.
//

import UIKit
import SVProgressHUD
// 进度指示器工具类，用于显示各种HUD信息
class NDProgressHUD {
    // 显示简短的消息
    static func show(message text: String) {
        DispatchQueue.main.async {
            SVProgressHUD.showInfo(withStatus: text)
            SVProgressHUD.dismiss(withDelay: 1.0)
        }
    }
    
    // 显示成功消息
    static func showSuccess(title: String, subtitle: String) {
        DispatchQueue.main.async  {
            SVProgressHUD.showSuccess(withStatus: subtitle)
            SVProgressHUD.dismiss(withDelay: 1.0)
        }
    }
    
    // 显示错误消息
    static func showError(title: String, subtitle: String) {
        DispatchQueue.main.async  {
            SVProgressHUD.showError(withStatus: subtitle)
            SVProgressHUD.dismiss(withDelay: 1.0)
        }
    }
    
    // 显示加载中的HUD
    static func showLoading() {
        DispatchQueue.main.async  {
            SVProgressHUD.show()
        }
    }
    
    static func showLoadingText(_ text:String) {
        DispatchQueue.main.async  {
            SVProgressHUD.show(withStatus: text)
        }
    }
    
    // 隐藏HUD
    static func hide() {
        DispatchQueue.main.async  {
            SVProgressHUD.dismiss()
        }
    }
}
